$NG.AllReady(function (page, { useAction, useBeforeClick, useValuesChange, useClick, useUpdateRow, subscribe, useUpdateRows }) {
    const mstform = $NG.getCmpApi("p_form_zljcgl_m")
    const dgrid1 = $NG.getCmpApi("p_form_zljcgl_d1")
    const getHeadValue = (str) => mstform.getItem(str).getValue()
    if (page.oType == 'add') {
        mstform.getItem("u_jclx").setValue({ value: 6870000000000412, label: '日常检查' })
        mstform.getItem("u_jclb").setValue('01')
        mstform.getItem("u_sfxyzg").setValue('02')
    }

    useValuesChange(() => {
        hiddenDetail()
        hiddenKey()
    }, "p_form_zljcgl_m.u_jclb")
    useValuesChange(() => {
        hiddenDetail()
        hiddenKey()
    }, "p_form_zljcgl_m.u_sfxyzg")

    // 隐藏明细
    function hiddenDetail() {
        const jclb = mstform.getItem("u_jclb").getValue()
        const zfzg = mstform.getItem("u_sfxyzg").getValue()
        console.log(`sss`, jclb, zfzg);
        if (jclb == '01' && zfzg == '01') {
            const tabs = $NG
                .getCompMap()
                .get("__Tabs__")[0]
                .getApi();

            tabs.updateItems((innerItems, activeKey) => {
                return [...innerItems.filter((item) => item.key == 'tabPanel_tabItem')];
            });

            tabs.setActiveKey('tabPanel_tabItem');
        } else {
            const tabs = $NG
                .getCompMap()
                .get("__Tabs__")[0]
                .getApi();

            tabs.updateItems((innerItems, activeKey) => {
                return [...innerItems.filter((item) => false)];
            });
        }
    }

    // 隐藏字段
    function hiddenKey() {
        const jclb = mstform.getItem("u_jclb").getValue()
        const zfzg = mstform.getItem("u_sfxyzg").getValue()
        console.log(`21421413123`, jclb, zfzg);
        let hidden = false
        if (jclb == '02' && zfzg == '01') {
            hidden = false
        } else {
            hidden = true
        }
        const keys = ['u_zgqx', 'u_zgzrr', 'u_zgjg']
        keys.forEach(el => {
            mstform.getItem(el).setProps({
                hidden
            })

        })
    }
})
